﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ArrayManage
{
    class Program
    {
        static void DisposeArray(double[] input,out double max,out double min,out double averge,out double sum )
        {
            min = input[0];
            max = input[0];
            sum = 0;
            for(int i = 0; i < input.Length; i++)
            {
                if (min > input[i])
                    min = input[i];
                else if (max < input[i])
                    max = input[i];
                sum += input[i];
            }
            averge = sum / input.Length;

            
        }
        static void Main(string[] args)
        {
            Console.WriteLine("输入数组元素");
            String str = Console.ReadLine();
            String[] array = str.Split(' '); //获取输入元素，元素为Spring类型
            double max, min, averge, sum;
            double[] input = new double[array.Length];//将Spring类型元素转为double型
            for(int i = 0; i < input.Length; i++)
            {
                input[i] = double.Parse(array[i]);
            }
            Program.DisposeArray(input, out max, out min, out averge, out sum);
            Console.WriteLine($"最大值为：{max}");
            Console.WriteLine($"最小值为：{min}");
            Console.WriteLine($"数组元素之和为：{sum}");
            Console.WriteLine($"平均数为：{averge}");
        }
    }
}
